

//引入connect用于连接UI组件与redux
import {connect} from 'react-redux'

//引入Count的UI组件
import CountUI from '../../components/Count'
import {createIncrementAction,createDecrementAction,createIncrementAsyncAction} from '../../redux/count_action'

// mapStateToProps函数返回值是对象
// 对象中的key:value作为状态传递给UI组件-------------<CountUI n="900"/>
function mapStateToProps(state){
  return {count:state}
}

// mapDispatchToProps函数的返回值是对象
// 对象中的key:value作为方法传递给UI组件------------<CountUI jia={jia}/>
function mapDispatchToProps(dispatch){
  return {
    jia:data => dispatch(createIncrementAction(data)),
    jian:data => dispatch(createDecrementAction(data)),
    jiaAsync:(data,time) => dispatch(createIncrementAsyncAction(data,time))
  }
}

// 创建并暴露一个Count的容器组件
export default connect(mapStateToProps,mapDispatchToProps)(CountUI)